/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 * 数据库建模模型类型枚举
 * @author lj
 * @date 2025-01-13
 */
@AllArgsConstructor
@Getter
public enum IsfdDatabaseModelSubTypeEnum {
    REGULAR("regular", "普通"),
    GENERAL("general", "通用"),
    SCENE("scene", "业务场景"),
    SYSTEM("system", "业务系统"),
    DATABASE("database", "要素库"),
    NODE("node", "节点");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdDatabaseModelSubTypeEnum isfdAnalysisApplicationTypeEnum = forValue(value);
        if (isfdAnalysisApplicationTypeEnum == null) {
            return null;
        }
        return isfdAnalysisApplicationTypeEnum.getDesc();
    }

    public static IsfdDatabaseModelSubTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdDatabaseModelSubTypeEnum isfdAnalysisApplicationTypeEnum : IsfdDatabaseModelSubTypeEnum.values()) {
            if (isfdAnalysisApplicationTypeEnum.getValue().equals(value)) {
                return isfdAnalysisApplicationTypeEnum;
            }
        }
        return null;
    }

    public static IsfdDatabaseModelSubTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdDatabaseModelSubTypeEnum isfdAnalysisApplicationTypeEnum : IsfdDatabaseModelSubTypeEnum.values()) {
            if (desc.equals(isfdAnalysisApplicationTypeEnum.getDesc())) {
                return isfdAnalysisApplicationTypeEnum;
            }
        }
        return null;
    }
}
